package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Dish;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {
    /**
     * 插入菜品
     * @param dish
     */
    @AutoFill(OperationType.INSERT)
    void insert(Dish dish);

    /**
     * 根据id查看菜品
     * @param id
     * @return
     */
    @Select("select * from dish where id = #{id}")
    Dish selectById(@Param("id") Long id);

    /**
     * 根据categoryId查看菜品
     * @param categoryId
     * @return
     */
    @Select("select * from dish where category_id = #{categoryId}")
    List<Dish> selectByCategoryId(@Param("categoryId") long categoryId);

    /**
     * 菜品分页查询
     * @param dish
     * @return
     */
    @Select("select * from dish ")
    List<Dish> selectDish(Dish dish);

    @AutoFill(OperationType.UPDATE)
    /**
     * 菜品起售/停售
     * @param dish
     */
    void modify(Dish dish);

    /**
     * 根据id删除菜品
     * @param ids
     */
    void deleteById(@Param("ids") List<Long> ids);

    /**
     * 条件查询菜品和口味
     * @param dish
     * @return
     */
    @Select("select * from dish where category_id = #{categoryId} and status = #{status}")
    List<Dish> list(Dish dish);

    /**
     * 根据菜品状态进行数量统计
     * @param dish
     * @return
     */
    @Select("select count(status) from dish where status = #{status}")
    Integer overviewDishesAmount (Dish dish);
}
